package com.example.bookshop.controller;

import com.example.bookshop.entity.Book;
import com.example.bookshop.service.HomeService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

/**
 * @auth shanyue
 * @date 2025年06月04日16:32
 */
@Controller
public class HomeController {

    @Resource
    private HomeService homeService;

    @GetMapping({"/", "/books"})
    public String index(Model model) {
        List<Book> books = homeService.findAllBooks();
        model.addAttribute("books", books);
        return "index";
    }

}
